import {token} from '@/services/Auth';
import {message} from 'antd';

export default {
  namespace: 'PLogin',

  state: {},

  effects: {
    * token({payload, callback}, {call}) {
      const response = yield call(token, payload);
      if (response.code === 0) {
        message.destroy();
        message.success('登陆成功');
        window.localStorage.setItem('token', response.data.tokenValue);
        window.localStorage.setItem('code', payload.code);
        callback && callback();
      }
    },
  },
};
